package com.meng.common.utils;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * @author xinqimeng
 * @version 1.0.0
 * @ClassName ConnectionUtils.java
 * @Description TODO
 * @createTime 2022年02月10日 11:33:00
 */
public class ConnectionUtils {

    public static Connection getConnection () throws Exception{
        //创建连接工厂
        ConnectionFactory connectionFactory = new ConnectionFactory();
        //主机地址;默认为 localhost
        connectionFactory.setHost("localhost");
        //连接端口;默认为 5672
        connectionFactory.setPort(5672);
        //虚拟主机名称;默认为 /
        connectionFactory.setVirtualHost("/");
        //连接用户名；默认为guest
        connectionFactory.setUsername("guest");
        //连接密码；默认为guest
        connectionFactory.setPassword("guest");
        return connectionFactory.newConnection();
    }

}
